﻿using System;
using System.Collections.Generic;

namespace Bilibili.Model.Video
{
    public sealed class WatchlaterItemModel
    {
        public string Aid { get; set; }
        public int Videos { get; set; }
        public string Tname { get; set; }
        public string Pic { get; set; }
        public string Title { get; set; }
        public string Desc { get; set; }
        public string Dynamic { get; set; }
        public long Cid { get; set; }
        public long Add_At { get; set; }
        public string AddAt
        {
            get
            {
                DateTime dtStart = new DateTime(1970, 1, 1);
                TimeSpan toNow = TimeSpan.FromSeconds(Add_At);
                DateTime dt = dtStart.Add(toNow).ToLocalTime();
                TimeSpan span = DateTime.Now - dt;
                if (span.TotalDays > 7)
                    return dt.ToString("yyyy-MM-dd");
                else if (span.TotalDays > 1)
                    return string.Format("{0}天前", (int)Math.Floor(span.TotalDays));
                else if (span.TotalHours > 1)
                    return string.Format("{0}小时前", (int)Math.Floor(span.TotalHours));
                else if (span.TotalMinutes > 1)
                    return string.Format("{0}分钟前", (int)Math.Floor(span.TotalMinutes));
                else if (span.TotalSeconds >= 1)
                    return string.Format("{0}秒前", (int)Math.Floor(span.TotalSeconds));
                else
                    return "1秒前";
            }
        }
        public OwnerModel Owner { get; set; }
        public List<PagesModel> Pages { get; set; }
        public int Progress { get; set; }
        public int Duration { get; set; }
        public string Display => $"{Videos}P {TimeSpan.FromSeconds(Duration):c}";
        public string State => Progress == -1 ? "已看完" : Progress != 0 ? "看到 " + TimeSpan.FromSeconds(Progress).ToString(@"mm\:ss") : "尚未观看";
    }
}